#include "maze_generator.h"
#include "huisu.hpp"

using namespace std;
//运行输入 g++ test.cpp maze_generator.cpp huisu.cpp -Ie:/Vscodec++/sf_ks/ -o test
int main() {
    int n = 9; // 迷宫大小（建议奇数，确保中间可通行）
    
    // 生成迷宫
    MazeGenerator generator;
    generator = MazeGenerator(n);
    generator.generateMaze();
    auto maze = generator.getMaze();
    generator.printMaze();

    // 找到起点
    Point start;
    bool foundStart = false;
    for (int i = 0; i < n && !foundStart; ++i) {
        for (int j = 0; j < n && !foundStart; ++j) {
            if (maze[i][j].type == MazeElement::START) {
                start = {i, j};
                foundStart = true;
            }
        }
    }

    if (!foundStart) {
        cout << "Error: No start point found in maze." << endl;
        return 1;
    }
    //cout<<1;
    // 执行贪心资源收集
    huisu solver(n);
    solver.generate_rp(maze);
    //cout<<2;
    solver.greedyCollect(start);
    // 输出路径
    cout << "path:" << endl;
    for (const auto& p : solver.getPath()) {
        cout << "(" << p.x << ", " << p.y << ") ";
    }
    cout << "score: " << solver.getScore() << endl;

    return 0;
}
